import QtQuick 1.0

Item {
    property bool paused : true
    id: calo
    width: map.width

    Image {
        id: wall
        source: "res/img/int_wall.png"
        fillMode: Image.TileHorizontally
    }

    Interface {
        id: gameInterface
    }

    Component {
        id: chestCreation

        Chest { }
    }

    function createChest(xPos, hasItemIn) {
        chestCreation.createObject(map, { x: xPos, y: 461, z: 0, hasItem: hasItemIn});
    }

    Component.onCompleted: {

    }

    Map {
        source: "res/map/scenery02.tmx"
        id: map

        Player {
            id: player
            startX: 30
            startY: 470
            z: 1
            level: "castleLevel"
            paused: calo.paused
        }

        Chest {
            id: chest
            x: 439
            y: 461
            z : 0

            hasItem: true
        }

        Component.onCompleted: {
            // adjust background
            wall.width = width;
        }
    }

    /* Scroll: call it to scroll scene based on player's position */
    function scroll(amount) {
        map.x -= amount;
        wall.x -= (amount / 2);
    }

    function resetPositions() {
        player.x = player.startX + 100;
        player.y = player.startY;

        map.x = 0;
        wall.x = 0;
    }
}
